home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_200 / 260_01 / zmodem.h < prev   
Text File  |  1988-02-23  |  5KB  |  108 lines

  1. /*
  2.  *   Z M O D E M . H     Manifest constants for ZMODEM
  3.  *    application to application file transfer protocol
  4.  *    01-15-87  Chuck Forsberg Omen Technology Inc
  5.  */
  6. #define ZPAD '*'        /* 052 Padding character begins frames */
  7. #define ZDLE 030        /* Ctrl-X Zmodem escape - `ala BISYNC DLE */
  8. #define ZDLEE (ZDLE^0100)       /* Escaped ZDLE as transmitted */
  9. #define ZBIN 'A'        /* Binary frame indicator */
  10. #define ZHEX 'B'        /* HEX frame indicator */
  11. #define ZBIN32 'C'      /* Binary frame with 32 bit FCS */
  12.  
  13. /* Frame types (see array "frametypes" in zm.c) */
  14. #define ZRQINIT 0       /* Request receive init */
  15. #define ZRINIT  1       /* Receive init */
  16. #define ZSINIT 2        /* Send init sequence (optional) */
  17. #define ZACK 3          /* ACK to above */
  18. #define ZFILE 4         /* File name from sender */
  19. #define ZSKIP 5         /* To sender: skip this file */
  20. #define ZNAK 6          /* Last packet was garbled */
  21. #define ZABORT 7        /* Abort batch transfers */
  22. #define ZFIN 8          /* Finish session */
  23. #define ZRPOS 9         /* Resume data trans at this position */
  24. #define ZDATA 10        /* Data packet(s) follow */
  25. #define ZEOF 11         /* End of file */
  26. #define ZFERR 12        /* Fatal Read or Write error Detected */
  27. #define ZCRC 13         /* Request for file CRC and response */
  28. #define ZCHALLENGE 14   /* Receiver's Challenge */
  29. #define ZCOMPL 15       /* Request is complete */
  30. #define ZCAN 16         /* Other end canned session with CAN*5 */
  31. #define ZFREECNT 17     /* Request for free bytes on filesystem */
  32. #define ZCOMMAND 18     /* Command from sending program */
  33. #define ZSTDERR 19      /* Output to standard error, data follows */
  34.  
  35. /* ZDLE sequences */
  36. #define ZCRCE 'h'       /* CRC next, frame ends, header packet follows */
  37. #define ZCRCG 'i'       /* CRC next, frame continues nonstop */
  38. #define ZCRCQ 'j'       /* CRC next, frame continues, ZACK expected */
  39. #define ZCRCW 'k'       /* CRC next, ZACK expected, end of frame */
  40. #define ZRUB0 'l'       /* Translate to rubout 0177 */
  41. #define ZRUB1 'm'       /* Translate to rubout 0377 */
  42.  
  43. /* zdlread return values (internal) */
  44. /* -1 is general error, -2 is timeout */
  45. #define GOTOR 0400
  46. #define GOTCRCE (ZCRCE|GOTOR)   /* ZDLE-ZCRCE received */
  47. #define GOTCRCG (ZCRCG|GOTOR)   /* ZDLE-ZCRCG received */
  48. #define GOTCRCQ (ZCRCQ|GOTOR)   /* ZDLE-ZCRCQ received */
  49. #define GOTCRCW (ZCRCW|GOTOR)   /* ZDLE-ZCRCW received */
  50. #define GOTCAN  (GOTOR|030)     /* CAN*5 seen */
  51.  
  52. /* Byte positions within header array */
  53. #define ZF0     3       /* First flags byte */
  54. #define ZF1     2
  55. #define ZF2     1
  56. #define ZF3     0
  57. #define ZP0     0       /* Low order 8 bits of position */
  58. #define ZP1     1
  59. #define ZP2     2
  60. #define ZP3     3       /* High order 8 bits of file position */
  61.  
  62. /* Bit Masks for ZRINIT flags byte ZF0 */
  63. #define CANFDX  01      /* Rx can send and receive true FDX */
  64. #define CANOVIO 02      /* Rx can receive data during disk I/O */
  65. #define CANBRK  04      /* Rx can send a break signal */
  66. #define CANCRY  010     /* Receiver can decrypt */
  67. #define CANLZW  020     /* Receiver can uncompress */
  68. #define CANFC32 040     /* Receiver can use 32 bit Frame Check */
  69.  
  70. /* Parameters for ZSINIT frame */
  71. #define ZATTNLEN 32     /* Max length of attention string */
  72.  
  73. /* Parameters for ZFILE frame */
  74. /* Conversion options one of these in ZF0 */
  75. #define ZCBIN   1       /* Binary transfer - inhibit conversion */
  76. #define ZCNL    2       /* Convert NL to local end of line convention */
  77. #define ZCRESUM 3       /* Resume interrupted file transfer */
  78. /* Management options, one of these in ZF1 */
  79. #define ZMNEW   1       /* Transfer if source newer or longer */
  80. #define ZMCRC   2       /* Transfer if different file CRC or length */
  81. #define ZMAPND  3       /* Append contents to existing file (if any) */
  82. #define ZMCLOB  4       /* Replace existing file */
  83. #define ZMSPARS 5       /* Encoding for sparse file */
  84. #define ZMDIFF  6       /* Transfer if dates or lengths different */
  85. #define ZMPROT  7       /* Protect destination file */
  86. /* Transport options, one of these in ZF2 */
  87. #define ZTLZW   1       /* Lempel-Ziv compression */
  88. #define ZTCRYPT 2       /* Encryption */
  89. #define ZTRLE   3       /* Run Length encoding */
  90.  
  91. /* Parameters for ZCOMMAND frame ZF0 (otherwise 0) */
  92. #define ZCACK1  1       /* Acknowledge, then do command */
  93.  
  94. long rclhdr();
  95.  
  96. /* Globals used by ZMODEM functions */
  97. int Rxframeind;         /* ZBIN ZBIN32, or ZHEX type of frame received */
  98. int Rxtype;             /* Type of header received */
  99. int Rxcount;            /* Count of data bytes received */
  100. extern Rxtimeout;       /* Tenths of seconds to wait for something */
  101. char Rxhdr[4];          /* Received header */
  102. char Txhdr[4];          /* Transmitted header */
  103. long Rxpos;             /* Received file position */
  104. long Txpos;             /* Transmitted file position */
  105. int Txfcs32;            /* TURE means send binary frames with 32 bit FCS */
  106. int Znulls;             /* Number of nulls to send at beginning of ZDATA hdr */
  107. char Attn[ZATTNLEN+1];  /* Attention string rx sends to tx on err */
  108.